package com.zhiyizhen.handheld.component.workspace.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.zhiyizhen.handheld.common.ScreenUtil;
import com.zhiyizhen.handheld.common.view.adapter.recyclerview.BaseAdapter;
import com.zhiyizhen.handheld.common.view.adapter.recyclerview.BaseViewHolder;
import com.zhiyizhen.handheld.component.workspace.bean.MySchedule;
import com.zhiyizhen.handheld.databinding.ItemMyWorkBinding;

/**
 * 我的排班
 */
public class MyWorkTimeAdapter extends BaseAdapter<MySchedule, MyWorkTimeAdapter.CarTypeViewHolder> {
    Context context;

    public MyWorkTimeAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @NonNull
    @Override
    public CarTypeViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new MyWorkTimeAdapter.CarTypeViewHolder(this, ItemMyWorkBinding.inflate(LayoutInflater.from(parent.getContext())));
    }

    static class CarTypeViewHolder extends BaseViewHolder<MySchedule> {

        private final ItemMyWorkBinding binding;

        public CarTypeViewHolder(BaseAdapter<MySchedule, MyWorkTimeAdapter.CarTypeViewHolder> adapter, ItemMyWorkBinding viewBinding) {
            super(adapter, viewBinding.getRoot());
            binding = viewBinding;
        }

        @Override
        public void bindData(MySchedule data) {
            binding.dateTv.setText(data.getWorkDate());
            binding.timeTv.setText(data.getTime());
            binding.contentLayout.setLayoutParams(new LinearLayout.LayoutParams(ScreenUtil.screenWidth(), ScreenUtil.dp2px(40)));
        }
    }
}
